<script setup lang="ts">
import { ref,onBeforeMount } from 'vue'

// remote方式获取主进程
// const remote = require("@electron/remote");
// const win = remote.getCurrentWindow()

const count = ref(0)
const msg = ref('Hello World!')
function closeWindow() {
  window.electronAPI.getCurrentWindow().minimize();
}
onBeforeMount(() => {
  // 向主进程发送消息 （等待测试）
  window.electron.sendMessage('getDataRequest', {name: '张三', age: 18});

  // 注册接收消息的回调
  window.electron.on('putDataResponse', (responseData) => {
    console.log('window.electron.on(\'getDataResponse\') 主进程推送的消息', responseData);
  });
})
</script>

<template>
  <h1>{{ msg }}</h1>

  <div class="card">
    <button type="button" @click="count++">count is {{ count }}</button>
    <button @click="closeWindow">Close Window</button>
    <p>
      Edit
      <code>components/HelloWorld.vue</code> to test HMR
    </p>
  </div>


</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>
